import Vue from 'vue'
import VueRouter from 'vue-router'
import Main from '../views/user/Main'
import Login from '../views/user/Login'
import Register from '../views/user/Register'
import UpdateUser from '../views/user/UpdateUser'
import UserPage from '../views/user/UserPage'
import AddOneArticle from '../views/article/AddOneArticle'
import QueryAllArticle from '../views/article/QueryAllArticle'
import QueryOneArticle from '../views/article/QueryOneArticle'
import AddArtide from '../views/admin/AddArtide'
import AdminLogin from '../views/admin/Login'
import AdminIndex from '../views/admin/Index'
import AdminUpdateAdminUser from '../views/admin/UpdateAdminUser'
import UpdateArtide from '../views/admin/UpdateArtide'

Vue.use(VueRouter);

const router = new VueRouter({
  mode: 'history',
  routes: [{
      path: '/user/',
      name: 'UserMain',
      component: Main,
      children: [{
          name: 'Login',
          path: "/user/login",
          component: Login
        },
        {
          name: 'Register',
          path: "/user/register",
          component: Register
        },
        {
          //查询全部文章
          name: 'QueryAllArticle',
          path: '/article/queryAllArticle',
          component: QueryAllArticle,
          // redirect: {
          //   name: 'QueryOneArticle'
          // },
          // children: [{
          // name: 'QueryOneArticle',
          // path: '/article/queryOneArticle/:article',
          // component: QueryOneArticle
          // }]
        },
      ]
    },
    {
      name: 'QueryOneArticle',
      path: '/article/queryOneArticle/:article',
      component: QueryOneArticle
    },
    {
      path: '/user/userPage',
      name: 'UserPage',
      component: UserPage
    },
    {
      path: '/user/updateUser',
      name: 'UpdateUser',
      component: UpdateUser
    },
    {
      path: '/article/addOneArticle',
      name: 'AddOneArticle',
      component: AddOneArticle
    },
    {
      path: '/admin/login',
      name: 'AdminLogin',
      component: AdminLogin
    },
    {
      path: '/admin/index',
      name: 'AdminIndex',
      component: AdminIndex
    },
    {
      path: '/admin/updateAdminUser',
      name: 'AdminUpdateAdminUser',
      component: AdminUpdateAdminUser
    },
    {
      path: '/admin/addArtide',
      name: 'AddArtide',
      component: AddArtide
    },
    {
      path: '/admin/updateArtide',
      name: 'UpdateArtide',
      component: UpdateArtide
    }
  ],
});

export default router;
